#include<iostream>

using namespace std;
#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;
class Solution {
public:
    int subarraySum(vector<int>& nums, int k) {
       for(int i=1;i<nums.size();i++)
       {
        nums[i]+=nums[i-1];
       }
       unordered_map<int,int>mp;
       mp[0]=1;
       int res=0;

       for(int i=0;i<nums.size();i++)
       {
        
        if(mp.find(nums[i]-k)!=mp.end())
        {
            res+=mp[nums[i]-k];
        }
        mp[nums[i]]++;
       }
       return res;
    }
};
int main()
{
    Solution s1;
    vector<int>nums(1,1);
    s1.subarraySum(nums,1);
}